﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OGS.Contracts;
using OGS.DataAccess;

namespace OGS.Web.Models.Admin
{
    public class ProductListModel
    {
        public List<Product> Products { get; set; }

        public List<Category> ParentCategories { get; set; }

        public List<Brand> Brands { get; set; }

        public SearchAttributes SearchAttributes { get; set; }

        public string Name { get; set; }

        public int ParentCategoryID { get; set; }

        public int BrandID { get; set; }

        public int CategoryID { get; set; }
            
      
        /// <summary>
        /// Populate List
        /// </summary>
        /// <param name="SearchAttributes"></param>
        public void Populate(string Name, int BrandID, int ParentCategoryID, int CategoryID, SearchAttributes SearchAttributes)
        {
            Product oProduct = new Product { CategoryID = CategoryID, BrandID = BrandID };
            oProduct.ProductLanguages = new List<ProductLanguage>();
            oProduct.ProductLanguages.Add(new ProductLanguage { Name = Name });

            this.Name = Name;
            this.ParentCategoryID = ParentCategoryID;
            this.CategoryID = CategoryID;
            this.BrandID = BrandID;

            //Get Products
            this.Products = DAProduct.Instance.SearchProduct(oProduct, SearchAttributes);

            //Get Categories
            this.ParentCategories = DACategory.Instance.GetCategories(0);
            this.ParentCategories.Insert(0, new Category { ID = 0, ComputedName = "All Parent Categories" });
            
            //Get Brands
            this.Brands = DABrand.Instance.GetBrands();
            this.Brands.Insert(0, new Brand { ID = 0, Name = "All Brands" });

        }

    }
}